package com.mtiiot.fsmanage.controller;



import com.mtiiot.fsmanage.server.LogServer;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@SuppressWarnings("all")
@Controller
public class LogController{

	@Autowired
    LogServer logServer;


    /**
     * 查询日志数据
     * @return
     */
    @RequestMapping(value="/log/logQuery.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object logQuery(String sysName,String l1Name,String l2Name,String l3Name,String logLevel,String times,String queryKeyWord,int count,String sort) throws Exception {
         Object obj=logServer.logQuery(sysName,l1Name,l2Name,l3Name,logLevel,times,queryKeyWord,count,sort);
         ObjectMapper mapper = new ObjectMapper();
         String jsonStr=mapper.writeValueAsString(obj);
         return jsonStr;
    }

    /**
     * 查询日志数据
     * @return
     */
    @RequestMapping(value="/log/logStatistics.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object logStatistics(String sysName,String l1Name,String l2Name,String l3Name,String logLevel,String times) throws Exception {
        Object obj=logServer.logStatistics(sysName,l1Name,l2Name,l3Name,logLevel,times);
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr=mapper.writeValueAsString(obj);
        System.out.println(jsonStr);
        return jsonStr;
    }

}